package org.future.task.core.util;

import java.util.concurrent.TimeUnit;

public class TimeIntervalWatch {

    private final int interval;

    private final TimeUnit unit;

    private long startTime;

    public TimeIntervalWatch(int interval, TimeUnit unit) {
        this.interval = interval;
        this.unit = unit;
    }

    public void start() {
        this.startTime = System.currentTimeMillis();
    }

    public boolean returnInterval() {
        long nowCurrentTimeMillis = System.currentTimeMillis();
        long interval = nowCurrentTimeMillis - startTime;
        long time = 0;
        switch (unit) {
            case SECONDS:
                time = interval / 1000;
                break;
            case MILLISECONDS:
                break;
            case DAYS:
            case HOURS:
            case MINUTES:
            case NANOSECONDS:
            case MICROSECONDS:
                break;
            default:
        }
        if (time >= this.interval) {
            startTime = nowCurrentTimeMillis;
            return true;
        }
        return false;
    }

}
